home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / bipl.zip / PROCS.ZIP / CALENDAT.ICN < prev    next >
Text File  |  1992-11-20  |  2KB  |  53 lines

  1. ############################################################################
  2. #
  3. #    File:     calendat.icn
  4. #
  5. #    Subject:  Procedure to get date from Julian Day Number
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     September 6, 1992
  10. #
  11. ###########################################################################
  12. #
  13. #  calendat(j) return a record with the month, day, and year corresponding
  14. #  to the Julian Date Number j.
  15. #
  16. ############################################################################
  17. #
  18. #  Acknowledgement:  This procedure is based on an algorithm given in
  19. #  "Numerical Recipes; The Art of Scientific Computing"; William H. Press,
  20. #  Brian P. Flannery, Saul A. Teukolsky. and William T. Vetterling;
  21. #  Cambrdayge University Press, 1986.
  22. #
  23. ############################################################################
  24.  
  25. record date1(month, day, year)
  26.  
  27. procedure calendat(julian)
  28.    local ja, jalpha, jb, jc, jd, je, gregorian
  29.    local month, day, year
  30.  
  31.    gregorian := 2299161
  32.  
  33.    if julian >= gregorian then {
  34.       jalpha := integer(((julian - 1867216) - 0.25) / 36524.25)
  35.       ja := julian + 1 + jalpha - integer(0.25 * jalpha)
  36.       }
  37.    else ja := julian
  38.  
  39.    jb := ja + 1524
  40.    jc := integer(6680.0 + ((jb - 2439870) - 122.1) / 365.25)
  41.    jd := 365 * jc + integer(0.25 * jc)
  42.    je := integer((jb - jd) / 30.6001)
  43.    day := jb - jd - integer(30.6001 * je)
  44.    month := je - 1
  45.    if month > 12 then month -:= 12
  46.    year := jc - 4715
  47.    if month > 2 then year -:= 1
  48.    if year <= 0 then year -:= 1
  49.  
  50.    return date1(month, day, year)
  51.  
  52. end
  53.